//
//  GuaShaViewController.m
//  PersonalHospital
//
//  Created by qianfeng on 15/12/12.
//  Copyright (c) 2015年 QianFeng. All rights reserved.
//

#import "GuaShaViewController.h"
#import "TranditionalShowModel.h"
#import "TranditionalShowCell.h"
@interface GuaShaViewController ()

@end

@implementation GuaShaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)paseData:(id)responseObject{
    NSArray * array=responseObject[@"data"];
    
    for (NSDictionary * dict in array) {
        
        NSArray * infoArray=dict[@"info"];
        
        NSDictionary * dict=infoArray[1];
        InfoModel * model=[[InfoModel alloc]initWithDictionary:dict error:nil];
        
        [self.dataSource addObject:model];
    }
    
    [self.tableView reloadData];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TranditionalShowCell * cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell==nil) {
        cell=[[TranditionalShowCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.buttonClick=^{
        [self playVidio:indexPath];
    };
    
    cell.model=self.dataSource[indexPath.row];
    return cell;
}

-(void)playVidio:(NSIndexPath *)indexPath{
    InfoModel * model=self.dataSource[indexPath.row];
    
    if (_buttonClick) {
        self.buttonClick(model.cureVideo);
    }
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return KTranditional_Scroll_Cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==0) {
        return 44;
    }
    return 0;
}


-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
    
    view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UILabel * name=[[UILabel alloc]init];
    name.frame=CGRectMake((KScreen_Size.width-80)/2, 0, 80, view.frame.size.height);
    name.textAlignment=NSTextAlignmentLeft;
    name.textColor=[UIColor blackColor];
    name.text=@"刮痧";
    name.font=[UIFont systemFontOfSize:18];
    UIButton * button=[[UIButton alloc]init];
    button.frame=CGRectMake((KScreen_Size.width-80), 0, 80,view.frame.size.height);
    [button setTitle:@"更多 > >" forState:UIControlStateNormal];
    button.titleLabel.textAlignment=NSTextAlignmentLeft;
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.titleLabel.font=[UIFont systemFontOfSize:14];
    [button addTarget:self action:@selector(buttonMoreClicked:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:name];
    [view addSubview:button];
    return view;
    
}

-(void)buttonMoreClicked:(UIButton *)button{

}
@end
